public class Login {
    public String userName = "root";
    public  String passWord = "123456";

    public void login(String userName, String passWord) {
        if (!this.userName.equals(userName)) {
            throw new UserNameException("用户名错误");
        }
            if(!this.passWord.equals(passWord)){
                throw new PassWordException("密码错误");
            }
    }

    public static void main(String[] args) {
        try {
            Login login = new Login();
            login.login("root","123");
        }catch (UserNameException e){
            e.printStackTrace();
            System.out.println("捕获到了用户名错误异常");
        }catch (PassWordException e){
            e.printStackTrace();
            System.out.println("捕获到了密码错误异常");
        }
        System.out.println("程序继续执行");
    }
}
